<template>
  <div ref="fuwfbf">
    <!-- <router-view></router-view>
    我是微信登录-广财校友卡 广财校友卡认证流程： -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="id" width="180" align="center" />
      <el-table-column prop="stuName" label="姓名" width="180" align="center" />
      <el-table-column prop="classname" label="班级" width="180" align="center" />
      <el-table-column prop="organizationName" label="单位名称" width="180" align="center" />
      <el-table-column prop="office" label="职务/职称" align="center" />
      <el-table-column prop="address" label="常住地" align="center" />
      <el-table-column prop="phone" label="手机号" align="center" />
      <el-table-column prop="alumni" label="校友组织" align="center" />
      <el-table-column label="审核" align="center" width="180" type="index">
        <template #default="{ row,$index }">
          <div class="ufhe">
            <el-button v-show="row.type == 0" type="success" style="text-align: center" @click="wuhu(row.stuName,$index,row.classname)">审核</el-button>
            <el-button v-show="row.type == 2" type="success" style="text-align: center" @click="insert(row,$index)">通过</el-button>
            <el-button  v-show="row.type == 2" type="danger" style="text-align: center" @click="bh(row.isrow)">驳回</el-button>
            <el-button  v-show="row.type == 3" type="danger" style="text-align: center" @click="cancel(row.isrow)">驳回</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center">
        <template #default="{ row }">
          <div class="ufhe">
            <span v-show="row.type == 1">审核中...</span>
            <span v-show="row.type == 0">待审核</span>
          </div>
          <div>
            <span v-show="row.type == 2">认证成功</span>
            <span v-show="row.type == 3">认证失败</span>
            <span v-show="row.type == 4">录入成功</span>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script lang="js" setup>
import { onMounted, ref } from "vue"
import {approval,search,upset} from '../../api/user'

onMounted(async () => {
  const res = await approval();
  tableData.value = res.data
})
const insert = async (e,b) => { await upset({id:e.id,stuName:e.stuName,classname:e.classname}); tableData.value[b].type = 4}
const wuhu = async (e,b,c) => {
  const res = await search({stuName:e,classname:c})
  console.log(res.data);
  if(res.data) {
   tableData.value[b].type = 2
  } else {
    tableData.value[b].type = 3
  }
}
const cancel = (e) => {
  console.log(e);
}
const tableData = ref([])
</script>
<style scoped>
.ufhe {
  text-align: center;
}
.cell {
  text-align: center;
}
</style>